/* 发现m  特别大，n, k很小，又是让你重复作变换，
 */
// 通过
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MAXN = 100;
struct Matrix {
  int m, n;
  int g[MAXN + 10][MAXN + 10];
  Matrix() {
    m = 0, n = 0;
    memset(g, 0, sizeof(g));
  }
} I; // I 为单位矩阵

int n, m, k;

Matrix operator*(const Matrix &A, const Matrix &B) {
  Matrix C;
  C.m = A.m, C.n = B.n;
  for (int i = 1; i <= C.m; ++i)
    for (int j = 1; j <= C.n; ++j)
      for (int k = 1; k <= A.n; ++k)
        C.g[i][j] += A.g[i][k] * B.g[k][j];
  return C;
}

Matrix fastpow(Matrix A, int p) {
  Matrix T = I;
  while (p) {
    if (p & 1)
      T = T * A;
    p >>= 1;
    A = A * A;
  }
  return T;
}

Matrix get(int x) {
  Matrix T = I;
  T.g[n + 1][x] = 1;
  return T;
}

Matrix eat(int x) {
  Matrix T = I;
  T.g[x][x] = 0;
  return T;
}

Matrix sw(int i, int j) {
  Matrix T = I;
  T.g[i][i] = T.g[j][j] = 0;
  T.g[i][j] = T.g[j][i] = 1;
  return T;
}

signed main() {
  cin >> n >> m >> k;
  I.m = I.n = n + 1;
  for (int i = 1; i <= I.n; ++i)
    I.g[i][i] = 1; // 单位矩阵

  Matrix A = I;
  Matrix temp;

  for (int i = 1; i <= k; ++i) {
    int x, y;
    char c;
    cin >> c;
    if (c == 'g')
      cin >> x, temp = get(x);
    else if (c == 'e')
      cin >> x, temp = eat(x);
    else if (c == 's')
      cin >> x >> y, temp = sw(x, y);
    A = A * temp;
  }
  A = fastpow(A, m);
  for (int i = 1; i <= n; ++i)
    cout << A.g[n + 1][i] << " "; // 最后一行

  /*
  a[n + 1] = 1;
  for (int k = 1; k <= n + 1; k++) {
    int sum = 0;
    for (int i = 1; i <= n + 1; i++) {

      sum += a[i] * A.g[i][k];
    }
    ans[k] = sum;
  }
  for (int k = 1; k <= n; k++)
    cout << ans[k] << " "; */

  return 0;
}
